package com.cloudfun.campusshare.entity;

import com.cloudfun.campusshare.common.constant.AsyncTaskBizType;
import com.cloudfun.campusshare.common.constant.AsyncTaskStatus;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

/**
 * Created by Huqin on 2020/6/4
 */
@Data
@Entity
@Table(name = "async_task")
@org.hibernate.annotations.Table(appliesTo = "async_task", comment = "异步任务")
public class AsyncTaskEntity extends BaseEntity {

    @Id
    @GenericGenerator(name = "id_uuid", strategy = "uuid")
    @GeneratedValue(generator = "id_uuid")
    @Column(name = "id", nullable = false, unique = true, length = 40)
    private String id;

    @Column(columnDefinition = ("varchar(32) not null comment '状态'"))
    @Enumerated(EnumType.STRING)
    private AsyncTaskStatus status;

    @Column(columnDefinition = ("int(6) not null comment '已执行次数'"))
    private Integer actualCount;

    @Column(columnDefinition = ("int(6) not null comment '期望执行次数'"))
    private Integer expectedCount;

    @Column(columnDefinition = ("varchar(32) not null comment '业务类型'"))
    @Enumerated(EnumType.STRING)
    private AsyncTaskBizType bizType;

    @Column(columnDefinition = ("varchar(40) not null comment '业务id'"))
    private String bizId;

    @Column(columnDefinition = ("varchar(512) default null comment '参数'"))
    private String params;

}
